

import os 
import shutil


data_dir = "./data/raw_data/SegRap2023_Training_Set_120cases_task2"
label_dir = "./data/SegRap2023_Training_Set_120cases_OneHot_Labels/Task002"
case_names = os.listdir(data_dir)

for case_name in case_names:

    if "segrap" not in case_name:
        continue

    need_to_save_dir = os.path.join(data_dir, case_name)
    shutil.copyfile(os.path.join(label_dir, f"{case_name}.nii.gz"), os.path.join(need_to_save_dir, f"seg_task2.nii.gz"))

print(f"处理成功")
# for case_name in case_names:
#     if "segrap" not in case_name:
#         continue

#     need_to_save_dir = os.path.join(data_dir, case_name)
#     for f in os.listdir(need_to_save_dir):
#         ## 判断是否存在分割文件，如果存在，则重命名
#         if f == f"{case_name}.nii.gz":
#             shutil.move(os.path.join(need_to_save_dir, f"{case_name}.nii.gz"), os.path.join(need_to_save_dir, f"seg.nii.gz"))
